static void
gtk_css_animated_style_init (GtkCssAnimatedStyle *style)
{
- style->style = gtk_css_static_style_new ();
}
GtkCssStyle *
-gtk_css_animated_style_new (void)
+gtk_css_animated_style_new (GtkCssStyle *style)
{
- return g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
+ GtkCssAnimatedStyle *result;
+
+ g_return_val_if_fail (GTK_IS_CSS_STYLE (style), NULL);
+
+ result = g_object_new (GTK_TYPE_CSS_ANIMATED_STYLE, NULL);
+
+ result->style = g_object_ref (style);
+
+ return GTK_CSS_STYLE (result);
}
void
static void
gtk_css_animated_style_create_css_transitions (GtkCssAnimatedStyle *style,
gint64 timestamp,
- GtkCssAnimatedStyle *source)
+ GtkCssStyle *source)
{
TransitionInfo transitions[GTK_CSS_PROPERTY_N_PROPERTIES] = { { 0, } };
GtkCssValue *durations, *delays, *timing_functions;
if (duration + delay == 0.0)
continue;
- start = gtk_css_animated_style_get_intrinsic_value (source, i);
- end = gtk_css_animated_style_get_intrinsic_value (style, i);
- if (_gtk_css_value_equal (start, end))
- {
- animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
- if (animation)
- style->animations = g_slist_prepend (style->animations, g_object_ref (animation));
- }
- else
+ if (GTK_IS_CSS_ANIMATED_STYLE (source))
{
- animation = _gtk_css_transition_new (i,
- gtk_css_style_get_value (GTK_CSS_STYLE (source), i),
- _gtk_css_array_value_get_nth (timing_functions, i),
- timestamp + delay * G_USEC_PER_SEC,
- timestamp + (delay + duration) * G_USEC_PER_SEC);
- style->animations = g_slist_prepend (style->animations, animation);
+ start = gtk_css_animated_style_get_intrinsic_value (GTK_CSS_ANIMATED_STYLE (source), i);
+ end = gtk_css_animated_style_get_intrinsic_value (style, i);
+ if (_gtk_css_value_equal (start, end))
+ {
+ animation = gtk_css_animated_style_find_transition (GTK_CSS_ANIMATED_STYLE (source), i);
+ if (animation)
+ style->animations = g_slist_prepend (style->animations, g_object_ref (animation));
+
+ continue;
+ }
}
+
+ animation = _gtk_css_transition_new (i,
+ gtk_css_style_get_value (source, i),
+ _gtk_css_array_value_get_nth (timing_functions, i),
+ timestamp + delay * G_USEC_PER_SEC,
+ timestamp + (delay + duration) * G_USEC_PER_SEC);
+ style->animations = g_slist_prepend (style->animations, animation);
}
}
static void
gtk_css_animated_style_create_css_animations (GtkCssAnimatedStyle *style,
- GtkCssAnimatedStyle *parent_style,
+ GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
- GtkCssAnimatedStyle *source)
+ GtkCssStyle *source)
{
GtkCssValue *durations, *delays, *timing_functions, *animations;
GtkCssValue *iteration_counts, *directions, *play_states, *fill_modes;
if (animation)
continue;
- if (source)
- animation = gtk_css_animated_style_find_animation (source, name);
+ if (GTK_IS_CSS_ANIMATED_STYLE (source))
+ animation = gtk_css_animated_style_find_animation (GTK_CSS_ANIMATED_STYLE (source), name);
if (animation)
{
if (keyframes == NULL)
continue;
- keyframes = _gtk_css_keyframes_compute (keyframes, provider, scale, GTK_CSS_STYLE (style), GTK_CSS_STYLE (parent_style));
+ keyframes = _gtk_css_keyframes_compute (keyframes, provider, scale, GTK_CSS_STYLE (style), parent_style);
animation = _gtk_css_animation_new (name,
keyframes,
void
gtk_css_animated_style_create_animations (GtkCssAnimatedStyle *style,
- GtkCssAnimatedStyle *parent_style,
+ GtkCssStyle *parent_style,
gint64 timestamp,
GtkStyleProviderPrivate *provider,
int scale,
- GtkCssAnimatedStyle *source)
+ GtkCssStyle *source)
{
if (source != NULL)
gtk_css_animated_style_create_css_transitions (style, timestamp, source);
return FALSE;
values = style_values_lookup (context);
- if (gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (values)))
+ if (!GTK_IS_CSS_ANIMATED_STYLE (values) ||
+ gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (values)))
return FALSE;
g_object_get (gtk_widget_get_settings (context->priv->widget),
}
else
{
- values = gtk_css_animated_style_new ();
+ values = gtk_css_static_style_new ();
- build_properties (context, GTK_CSS_ANIMATED_STYLE (values)->style, info->decl, &priv->relevant_changes);
+ build_properties (context, values, info->decl, &priv->relevant_changes);
/* These flags are always relevant */
priv->relevant_changes |= GTK_CSS_CHANGE_SOURCE;
}
style_info_set_values (info, NULL);
values = style_values_lookup (context);
+ values = gtk_css_animated_style_new (values);
if (values != current)
gtk_css_animated_style_create_animations (GTK_CSS_ANIMATED_STYLE (values),
- priv->parent ? GTK_CSS_ANIMATED_STYLE (style_values_lookup (priv->parent)) : NULL,
+ priv->parent ? style_values_lookup (priv->parent) : NULL,
timestamp,
GTK_STYLE_PROVIDER_PRIVATE (priv->cascade),
priv->scale,
gtk_style_context_should_create_transitions (context)
- ? GTK_CSS_ANIMATED_STYLE (current)
+ ? current
: NULL);
if (gtk_css_animated_style_is_static (GTK_CSS_ANIMATED_STYLE (values)))
- change &= ~GTK_CSS_CHANGE_ANIMATE;
+ {
+ change &= ~GTK_CSS_CHANGE_ANIMATE;
+ }
else
- change |= GTK_CSS_CHANGE_ANIMATE;
+ {
+ change |= GTK_CSS_CHANGE_ANIMATE;
+ style_info_set_values (info, values);
+ }
_gtk_style_context_update_animating (context);
if (current)
changes = _gtk_bitmask_new ();
changes = _gtk_bitmask_invert_range (changes, 0, _gtk_css_style_property_get_n_properties ());
}
+
+ g_object_unref (values);
}
else
{
changes = gtk_css_style_compute_dependencies (current, parent_changes);
if (!_gtk_bitmask_is_empty (changes))
- update_properties (context, GTK_CSS_ANIMATED_STYLE (current)->style, info->decl, changes);
+ {
+ if (GTK_IS_CSS_ANIMATED_STYLE (current))
+ update_properties (context, GTK_CSS_ANIMATED_STYLE (current)->style, info->decl, changes);
+ else
+ update_properties (context, current, info->decl, changes);
+ }
gtk_style_context_update_cache (context, parent_changes);
}